package yxy.game.pm2.command.shop;

import yxy.cherry.game.base.message.MessageEmitterHandler;
import yxy.cherry.game.base.message.annotation.MessageSource;
import yxy.cherry.game.base.message.annotation.MessageType;
import yxy.game.pm2.Result;
import yxy.game.pm2.command.Command;
import yxy.game.pm2.message.ShopMessage;
import yxy.game.pm2.module.shop.handle.StairwayShopHandle;

/** 商店 天梯商店 */
@MessageType(proto = Command.StairwayShop, classtype = ShopMessage.StairwayShopRequest.class)
public class CMD_StairwayShop extends Command<ShopMessage.StairwayShopRequest> {

	@Override
	public void execute(MessageSource messageSource, ShopMessage.StairwayShopRequest request) {
		String playerCode = messageSource.getTag();
		// TODO 处理请求参数

		ShopMessage.StairwayShopResponse.Builder response = ShopMessage.StairwayShopResponse.newBuilder();

		response.addAllGoods(new StairwayShopHandle().goods(playerCode));

		send(messageSource, response, Result.Success);
	}

	private void send(MessageSource messageSource, ShopMessage.StairwayShopResponse.Builder response, Result result) {
		response.setResult(result.packResult());
		MessageEmitterHandler.getInstance().send(messageSource, response.build());
	}
}